package com.zbl.zblproject.core.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zbl.zblproject.core.entity.CartItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author youlanqiang
 * @version 1.0
 * @date 2019/1/16
 */
@Repository
public interface CartItemMapper extends BaseMapper<CartItem> {

    @Select("SELECT * FROM zbl_carts WHERE user_id = #{userId} AND goods_id = #{goodsId}")
    CartItem selectCartItemByUserIdAndGoodsId(@Param("userId") int userId,
                                              @Param("goodsId") int goodsId);

    @Select("SELECT * FROM zbl_carts WHERE user_id = #{userId}")
    List<CartItem> selectCartItemByUserId(@Param("userId") int userId);
}
